//
//  UIWindow+Extension.swift
//  ifanr
//
//  Created by 😱😱 on 16/9/12.
//  Copyright © 2016年 😱😱. All rights reserved.
//

import UIKit

extension UIWindow {
    public func switchViewController() {
        let lastVersion  = NSUserDefaults.standardUserDefaults().objectForKey(StringConstant.BUNDLEVERSION) as? String
        let currentVersion = NSBundle.mainBundle().infoDictionary![StringConstant.BUNDLEVERSION] as! String
        let boolLoadNewfeature = NSUserDefaults.standardUserDefaults().boolForKey(StringConstant.BOOLLOADNEWFEATURE)
        
        if lastVersion != nil {
            if  boolLoadNewfeature  {
                self.rootViewController = IFBaseNavigationController(rootViewController: MainViewController())
                
            } else {
                self.rootViewController = NewFeatureController()
            }
        } else {
            self.rootViewController = NewFeatureController()
            // 将当前的版本号存进沙盒
            NSUserDefaults.standardUserDefaults().setObject(currentVersion, forKey: StringConstant.BUNDLEVERSION)
            NSUserDefaults.standardUserDefaults().synchronize()
        }
    }
}
